package com.mayikt.manage;

import com.mayikt.base.BaseResponse;
import com.mayikt.constant.HttpConstant;
import com.mayikt.dto.resp.UserRespDTO;
import com.mayikt.service.feign.MemberInfoServiceFeign;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WxMpServiceManage {
    @Autowired
    private MemberInfoServiceFeign memberInfoServiceFeign;

    public WxMpXmlOutMessage handle(Long userId, String openId) {
        // 正常业务逻辑以下两个方法可以封装成一个借口进行操作WxMpServiceManage
        // 先根据openid 查询是否已经关联  ---会员服务
        BaseResponse<UserRespDTO> userRespDtoBaseResponse = memberInfoServiceFeign.selectByOpenId(openId);
        if (userRespDtoBaseResponse.getCode().equals(HttpConstant.RPC_RESULT_SUCCESS)) {
            return null;
        }
        // 如果没有关注过的情况下  update ---会员服务
        memberInfoServiceFeign.updateUseOpenId(userId, openId);
        return null;
    }
}